<%@ page language="java" pageEncoding="UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%@ include file="../../common/common.jsp" %>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>${menu_name } - ${title }</title>
</head>
<link href="${ctx }/static/plugins/chosen_v1.6.2/chosen.css" rel="stylesheet" />
<body <%@ include file="../../common/skin.jsp" %>>
<%@ include file="../../common/head.jsp" %>
<%@ include file="../../common/menu.jsp" %>
<div class="J_content">
	<div class="mt20 plr20">
		<form action="${ctx }/channel/leader/list" id="queryForm" method="post">
			<div class="J_toolsBar clearfix">
				<div class="t_label">姓名:</div>
				<div class="t_text ml10">
					<input placeholder="姓名" type="text" name="name" id="name" value="${leaderQueryDTO.name }"/>
				</div>
				<div class="t_label ml10">职位:</div>
				<div class="t_text ml10">
					<input placeholder="职位" type="text" name="position" id="position" value="${leaderQueryDTO.position }"/>
				</div>
				<div class="t_button mgl30">
					<a class="abtn red" href="javascript:myQuery();">
						<i class="icon"></i>查询
					</a>
				</div>
				<div class="t_button ml10">
					<a class="abtn blue" href="javascript:myEdit();">
						<i class="icon"></i>新增
					</a>
				</div>
				<div class="t_label ml10">
					记录数：<label style="color: red;" id="total">${page.totalCount }</label>
				</div>
			</div>

			<div class="J_table mt20">
				<div class="t_table">
					<table>
						<thead>
						<tr>
							<td>
								<span>序号</span>
							</td>
							<td>
								<span>姓名</span>
							</td>
							<td>
								<span>职位</span>
							</td>
							<td>
								<span>排序</span>
							</td>
							<td>
								<span>操作</span>
							</td>
						</tr>
						</thead>
						<tbody>
						<c:choose>
							<c:when test="${page.list != null && page.totalCount > 0 }">
								<c:forEach items="${page.list }" var="u" varStatus="status">
									<tr>
										<td>
											<div class="t_text tc">
													${status.index+1 }
											</div>
										</td>
										<td>
											<div class="t_text tc">
													${u.name }
											</div>
										</td>
										<td>
											<div class="t_text tc">
													${u.position }
											</div>
										</td>
										<td>
											<div class="t_text tc">
													${u.sort }
											</div>
										</td>
										<td>
											<div class="t_link">
												<a href="javascript:myEdit('${u.id }');"><i class="icon"></i>编辑</a>
												<a href="javascript:updStatus('${u.id }', '0');"><i class="icon"></i>删除</a>
											</div>
										</td>
									</tr>

								</c:forEach>
							</c:when>
							<c:otherwise>
								<tr>
									<td colspan="8">
										<div class="J_null mt40">
											<img src="${ctx }/static/images/null.png">
											<p>暂无相关数据</p>
										</div>
									</td>
								</tr>
							</c:otherwise>
						</c:choose>
						</tbody>
					</table>
				</div>
				<%@ include file="../../common/pager.jsp"%>
			</div>
		</form>
	</div>
</div>
<script src="${ctx }/static/plugins/chosen_v1.6.2/chosen.jquery.js"></script>
<script type="text/javascript">
	function myEdit(id){
		var loadIdx = layer.load();
		var title = '添加友情链接';
		if(!id){
			id = '';
		}else{
			title = '修改友情链接';
		}
		$.post('${ctx}/channel/leader/add?id='+id, {}, function(str){

			layer.close(loadIdx);

			layer.open({
				title : title,
				type : 1,
				area : ['600px', '400px'],
				content : str,
				btn : ['确定', '取消'],
				yes : function(index, layero){
					$('#editForm').submit();
				},
				btn2 : function(index, layero){
					layer.close(index);
				}
			});
		});
	}

	function mySubmit(){
		$('#editForm').submit();
	}

	function myQuery(){
		$('#queryForm').submit();
	}
	function updStatus(id, status){
		var content = '';
		if(status == '1'){
			content = '确认要恢复数据吗？';
		}else{
			content = '确认要删除数据吗？';
		}

		layer.confirm(content, function(index){
			layer.close(index);
			var loadIdx = layer.load();
			$.ajax({
				url : '${ctx}/channel/leader/doDelete',
				type : 'post',
				data : {
					'id' : id,
				},
				traditional : true,
				success : function(result){
					layer.close(loadIdx);
					if(result.success){
						layer.alert('操作成功', function(){
							window.location.reload();
						});
					}else{
						layer.alert('操作失败');
					}
				}
			});
		});
	}
</script>
</body>
</html>